<extend name="common:base" />

<block name="content">
    <div style="height: 32px;">
        <ul class="nav nav-tabs pull-left">
            <li class="active"><a href="{{:url('scratch/index')}}" class="index-url">刮刮乐</a></li>
        </ul>
    </div>

    <table class="table table-bordered table-hover top10" style="margin-bottom: 10px; font-size: 12px;">
        <tr class="table-header" style="background-color: #EFEFEF;">
            <th>id</th>
            <th>scratch_id</th>
            <th>可抽次数</th>
            <th>奖品名称</th>
            <th>奖品图片</th>
            <th>已选人数</th>
            <th>概率</th>
            <th>排序/降序</th>
            <th>发布时间</th>
            <th>是否有奖</th>
            <th style="text-align: center;">状态</th>
            <th style="text-align: center;">操作</th>
        </tr>
        <volist name="data" id="voart">
            <tr>
                <td>{{$voart.id}}</td>
                <td>{{$voart.scratch_id}}</td>
                <td>{{$voart.select_num}}</td>
                <td>{{$voart.prize_name}}</td>
                <td>
                    <img class="artlists-faceimg show-faceimg" src="{{$voart.img_url}}">
                </td>
                <td>{{$voart.select_num}}</td>
                <td>{{$voart.probability}}</td>
                <td>{{$voart.listorder}}</td>
                <td>{{$voart.created}}</td>
                <td>{{$voart.type}}</td>
                <td style="text-align: center;">
                    <eq name="voart.status" value="1">
                        <a class="btn btn-success btn-xs btn-editstatus" data-url="/index.php/admin/scratch/edit_prize_status?status=0&id={{$voart.id}}">开启</a>
                        <else/>
                        <a class="btn btn-default btn-xs btn-editstatus" data-url="/index.php/admin/scratch/edit_prize_status?status=1&id={{$voart.id}}">关闭</a>
                    </eq>
                </td>
                <td style="text-align: center;">
                    <a href="{{:url('scratch/win_list', array('scratch_id' => $voart['scratch_id'], 'prize_id' => $voart['id']))}}" class="btn btn-warning btn-xs">中奖列表</a>
                    <a href="{{:url('scratch/edit_page', array('prize_id' => $voart['id']))}}" class="btn btn-warning btn-xs">编辑</a>
                </td>
            </tr>
        </volist>
        <tr class="table-header" style="background-color: #EFEFEF;">
            <th>id</th>
            <th>scratch_id</th>
            <th>可抽次数</th>
            <th>奖品名称</th>
            <th>奖品图片</th>
            <th>已选人数</th>
            <th>概率</th>
            <th>排序/降序</th>
            <th>发布时间</th>
            <th>是否有奖</th>
            <th style="text-align: center;">状态</th>
            <th style="text-align: center;">操作</th>
        </tr>
    </table>
    <div class="page-info">
        <div id="page_info"></div>
        <input type="hidden" id="allpages" value="{{$allpages}}" />
        <input type="hidden" id="nowpage" value="{{$nowpage}}" />
    </div>
</block>

<block name="footer">
    <script src="/static/js/laypage/laypage.js"></script>
    <script>
        // 清空 cookie 上一页 url
        $.cookie('edit_back_referrer', '', {path: '/'});

        // 实例化时间控件 laydate
        laydate.render({
            elem: '#datetime_start', //指定元素
            format: 'yyyy-MM-dd',
        });
        laydate.render({
            elem: '#datetime_end', //指定元素
            format: 'yyyy-MM-dd',
        });

        // ajax 分页
        laypage({
            cont: 'page_info',
            pages: $('body #allpages').val(),
            curr: function(){
                var page = $('body #nowpage').val();
                return page ? page : 1;
            }(),
            skip: true, // 分页跳转
            jump: function(e, first){
                if(!first){
                    layer.load(0, {shade: [0.1, '#FFF']}); // 加载层
                    var formData = $('form[name="searchForm"]').serialize();
                    var url = '/admin/article/index?page=' + e.curr + '&' + formData;

                    window.location.href = url;
                    return false;
                }
            }
        });
    </script>
</block>